<template>
    <div class="body">
    <div class="header">
    </div>
    <img
      src="../../assets/img/kitchen/1@2x.png"
      class="images"
      alt=""
    >
    <!-- g购物卡 -->
    <div class="six">
      <ul>
        <li @click="nav({goods_id:7704})">
          <div class="btn">立即抢购></div>
        </li>
        <li @click="nav({goods_id:7708})">
          <div class="btn">立即抢购></div>
        </li>
        <li @click="nav({goods_id:7711})">
          <div class="btn">立即抢购></div>
        </li>
        <li @click="nav({goods_id:7714})">
          <div class="btn">立即抢购></div>
        </li>
      </ul>
    </div>
    <!-- title -->
    <img
      src="../../assets/img/kitchen/2@2x.png"
      class="images"
      alt=""
    >
    <div class="box">
      <!-- 快乐 -->
      <div class="goods">
        <!-- :autoplay="5000" -->
        <van-swipe
          class="me-swipe"
          :duration="700"
          :autoplay="5000"
          style="height:10rem;"
          :show-indicators=false
        >
          <van-swipe-item
            v-for="item in list"
            :key="item.goods_id"
          >
            <ul>
              <li
                v-for="itemr in item"
                :key="itemr.goods_id"
                @click="nav(itemr)"
              >
                <img
                  :src="itemr.goods_img"
                  class="imge"
                  alt=""
                >
                <div class="Box">
                  <div class="text-Dev">
                    {{itemr.goods_name}}
                  </div>
                  <div class="money-Dev">
                    ¥
                    <span>{{itemr.active_price}}</span>
                  </div>
                </div>

                <span class="btn">
                  立即购买
                </span>
              </li>
            </ul>
          </van-swipe-item>
        </van-swipe>
        <div class="iteme">
          <ul>
            <li
              v-for="item in lister"
              :key="item.goods_id"
              @click="nav(item)"
            >
              <div class="back">
                <img
                  class="one-hit"
                  :src="item.goods_img"
                  alt=""
                >
              </div>

              <div class="text-one"> {{item.goods_name}}</div>
              <div class="money-Hot">
                <span>¥</span>
                <span>{{item.active_price}}</span>
              </div>
              <div class="Go-hot">
                立即购买
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <img
      src="../../assets/img/kitchen/3@2x.png"
      class="images"
      alt=""
    >
    <div class="box">
      <!-- 童趣精选 -->
      <div class="item">
        <ul>
          <li
            v-for="item in atr"
            :key="item.goods_id"
            @click="nav(item)"
          >
            <img
              :src="item.goods_img"
              class="imge"
              alt=""
            >
            <div class="Box">
              <div class="text-Dev">
                {{item.goods_name}}
              </div>
              <div class="money-Dev">
                ¥
                <span>{{item.active_price}}</span>
              </div>
            </div>
            <span class="btn">
              立即购买
            </span>
          </li>
        </ul>
      </div>
      <div class="happy">
        <ul>
          <li
            v-for="item in atrdev"
            :key="item.goods_id"
            @click="nav(item)"
          >
            <div class="back">
              <img
                class="one-hit"
                :src="item.goods_img"
                alt=""
              >
            </div>

            <div class="text-one"> {{item.goods_name}}</div>
            <div class="money-Hot">
              <span>¥</span>
              <span>{{item.active_price}}</span>
            </div>
            <div class="Go-hot">
              立即购买
            </div>
          </li>
        </ul>
      </div>
    </div>
    <img
      src="../../assets/img/kitchen/4@2x.png"
      class="imas"
      alt=""
      @click="ping"
    >
    <!-- 置顶 -->
    <div
      class="totop"
      id="totop"
      @click="backTop"
      v-show="btnFlag"
    >
      <!-- <i class="iconfont icon-zhiding"></i> -->
    </div>
  </div>
</template>

<script>
import bridge from '../../js/js1'
import { index, Coupondev } from '@/api/index'
import { share } from '../../js/public'
import { getSystem, openApp, getUrlQuery, parseKeyValue } from '../../js/js'
export default {
  // 组件名称
  name: '',
  // 局部注册的组件
  components: {},
  // 组件参数 接收来自父组件的数据
  props: {},
  // 组件状态值
  data () {
    return {
      list: [],
      lister: [],
      listdev: [],
      show: false,
      system: getSystem(),
      atr: [],
      atrdev: [],
      listerdev: [],
      share: true,
      scrollTop: 0,
      btnFlag: false,
      showTips: false,
    }
  },
  destroyed () {
    window.removeEventListener('scroll', this.scrollToTop);
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 生命周期钩子   注：没用到的钩子请自行删除
  /**
  * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
  */
  created () {
    this.create()
  },
  /**
  * el 被新创建的 vm.el 替换，并挂载到实例上去之后调用该钩子。
  * 如果 root 实例挂载了一个文档内元素，当 mounted 被调用时 vm.el 也在文档内。
  */
  mounted () {
    window.addEventListener('scroll', this.scrollToTop)
    share({
      title: '幸福厨房！',
      desc: '品质追求,时尚体验,健康生活,精品厨房用具低至6.7折起！',
      imgUrl: 'https://download.yuanfuda933.com/h5/images/kitchen.png',
      shareUrl: 'https://download.yuanfuda933.com/h5/other2.html#/kitchen',
      share: this.share,
    })
  },
  // 组件方法
  methods: {
    ping () {
      window.location.href = 'yfd://yfdmall:8080/homePage?categoryId=404'
    },
    // 点击图片回到顶部方法，加计时器是为了过渡顺滑
    backTop () {
      const that = this
      let timer = setInterval(() => {
        let ispeed = Math.floor(-that.scrollTop / 5)
        document.documentElement.scrollTop = document.body.scrollTop = that.scrollTop + ispeed
        if (that.scrollTop === 0) {
          clearInterval(timer)
        }
      }, 16)
    },
    // 为了计算距离顶部的高度，当高度大于60显示回顶部图标，小于60则隐藏
    scrollToTop () {
      const that = this
      let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
      that.scrollTop = scrollTop
      // console.log(that.scrollTop);
      if (that.scrollTop > 800) {
        that.btnFlag = true
      } else {
        that.btnFlag = false
      }
    },
    async create () {
      try {
        const res = await index({
          id: 86
        })
        console.log(res.data.data.types);
        var atrdev = res.data.data.types[0].goods.slice(0, 6)
        this.lister = res.data.data.types[0].goods.slice(6, 8)
        var resultdev = []
        for (var i = 0; i < atrdev.length; i += 2) {
          resultdev.push(atrdev.slice(i, i + 2));
        }
        this.list = resultdev
        console.log(this.list);
        this.atr = res.data.data.types[1].goods.slice(0, 1)
        // console.log(this.atr);
        this.atrdev = res.data.data.types[1].goods.slice(1, 30)
      } catch (err) {
        console.log('错误');
      }
    },
    // 跳转下载
    nav (item) {
      console.log(item.goods_id);
      // window.locaition.href = 'http://yuanfuda933.oss-cn-zhangjiakou.aliyuncs.com/yfdMall_1_v1.0.1.apk?squId=' + 'item.goods._id'
      window.location.href = 'yfd://yfdmall:8080/goodsDetail?spuId=' + item.goods_id
    },
    href (uri, blank = true) {
      const a = document.createElement('a')
      a.style.display = 'none'
      a.href = uri
      if (blank) a.setAttribute('target', '_blank')
      document.body.appendChild(a)
      a.click()
      setTimeout(t => {
        document.body.removeChild(a)
      }, 0)
    },
  }
}
</script>

<style scoped lang="less">
.body {
  overflow: hidden;
  min-width: 320px;
  max-width: 750px;
  width: 10rem;
  // height: 86rem;
  margin: 0 auto;
  line-height: 1.5;
  background: -webkit-linear-gradient(left, #6f81eb, #857eee, #6b80eb, #4083de);
  font-family: Arial, Helvetica;
  .moy {
    width: 3.733333rem;
    height: 0.933333rem;
    margin: 0.266667rem auto;
    border-radius: 0.65rem;
    font-size: 0.426667rem;
    font-weight: 600;
    color: #e86077;
    text-align: center;
    line-height: 0.933333rem;
    border: 0.026667rem solid #e86077;
    background: #ffffff;
  }
  .totop {
    position: fixed;
    width: 1.2rem; /* 40/16 */
    height: 1.2rem;
    border-radius: 1.25rem /* 20/16 */;
    opacity: 0.8;
    background: url("../../assets/ding.png") no-repeat;
    background-size: contain;
    box-shadow: 0 1px 5px 0 #e0e0e0;
    right: 0.125rem; /* 18/16 */
    bottom: 3rem; /* 64/16 */
    z-index: 1100;
    -webkit-transition: opacity 0.5s;
    transition: opacity 0.5s;
  }
  .header {
    background: url("../../assets/img/kitchen/header.png") no-repeat;
    background-size: contain;
    width: 10rem;
    height: 15.306667rem;
    overflow: hidden;
  }
  // g购物卡
  .six {
    width: 10rem;
    margin: 0 auto;
    // height: 4.773333rem;
    box-sizing: border-box;
    ul {
      overflow: hidden;
      li {
        margin-left: 0.17rem;
        width: 4.773333rem;
        height: 2.266667rem;
        float: left;
        .btn {
          width: 1.8rem;
          height: 0.453333rem;
          font-size: 0.266667rem;
          color: #ffcada;
          margin-top: 1.3rem;
          margin-left: 2.3rem;
          text-align: center;
          border-radius: 0.233333rem;
          line-height: 0.453333rem;
          background: -webkit-linear-gradient(left, #fe5d31, #fd2732);
          animation: mymove 2s infinite;
          -webkit-animation: mymove 2s infinite; /*Safari and Chrome*/
          animation-direction: alternate; /*轮流反向播放动画。*/
          animation-timing-function: ease-in-out; /*动画的速度曲线*/
          /* Safari 和 Chrome */
          -webkit-animation: mymove 2s infinite;
          -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
        }
      }
      li:nth-child(1) {
        background: url("../../assets/img/kitchen/110@2x.png") no-repeat;
        background-size: contain;
      }
      li:nth-child(2) {
        background: url("../../assets/img/kitchen/230@2x.png") no-repeat;
        background-size: contain;
      }
      li:nth-child(3) {
        background: url("../../assets/img/kitchen/590@2x.png") no-repeat;
        background-size: contain;
      }
      li:nth-child(4) {
        background: url("../../assets/img/kitchen/1000@2x.png") no-repeat;
        background-size: contain;
      }
    }
  }
  .images {
    width: 10rem;
    height: 1.946667rem;
    margin: 0.373333rem auto;
  }
  .box {
    position: relative;
    width: 10rem;
    margin: 0 auto;
    box-sizing: border-box;
    overflow: hidden;
    // opacity: 0.9;
    // -moz-opacity: 0.9;
    // filter: alpha(opacity=90);
  }
  .goods {
    width: 10rem;
    margin: 0 auto;
    overflow: hidden;
    .van-swipe {
      margin-left: 0.203333rem;
      width: 10rem;
      // /deep/.van-swipe-item {
      //   width: 9.6rem;
      // }
      li:nth-child(1) .Box {
        position: absolute;
        right: 5%;
        top: 12%;
        border-radius: 0.266667rem;
        width: 4rem;
        height: 2.293333rem;
        background: -webkit-linear-gradient(left, #208fec, #7d6ede, #b087f5);
      }
      li:nth-child(2) .Box {
        position: absolute;
        left: 5%;
        top: 12%;
        border-radius: 0.266667rem;
        width: 4rem;
        height: 2.293333rem;
        background: -webkit-linear-gradient(left, #208fec, #7d6ede, #b087f5);
      }
      li:nth-child(2) .imge {
        float: right;
        width: 4.133333rem;
        height: 4.133333rem;
        background: #dddddd;
        margin-top: 0.366667rem;
        margin-right: 0.466667rem;
        border-radius: 0.166667rem;
      }
      li:nth-child(2) .btn {
        position: absolute;
        right: 65%;
        top: 73%;
        width: 1.946667rem;
        height: 0.586667rem;
        font-size: 0.32rem;
        text-align: center;
        line-height: 0.586667rem;
        color: #ffffff;
        background: -webkit-linear-gradient(top, #b22ff8, #1b82f1);
        border-radius: 0.4rem;
        animation: mymove 2s infinite;
        -webkit-animation: mymove 2s infinite; /*Safari and Chrome*/
        animation-direction: alternate; /*轮流反向播放动画。*/
        animation-timing-function: ease-in-out; /*动画的速度曲线*/
        /* Safari 和 Chrome */
        -webkit-animation: mymove 2s infinite;
        -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
      }
      ul li {
        position: relative;
        overflow: hidden;
        width: 9.6rem;
        height: 4.88rem;
        background: -webkit-linear-gradient(left, #edf4f6, #e3f4fc);
        border-radius: 0.266667rem;
        margin-bottom: 0.266667rem;
        .imge {
          width: 4.133333rem;
          height: 4.133333rem;
          background: #dddddd;
          margin-top: 0.366667rem;
          margin-left: 0.466667rem;
          border-radius: 0.166667rem;
        }
        .text-Dev {
          margin: 0.133333rem auto;
          color: #ffffff;
          width: 3.413333rem;
          height: 1.173333rem;
          font-size: 0.426667rem;
          font-weight: 600;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
        }
        .money-Dev {
          position: absolute;
          top: 61%;
          left: 8%;
          width: 3.4rem;
          height: 0.8rem;
          font-weight: 600;
          font-size: 0.32rem;
          // font-weight: 600;
          color: #ffffff;
          span {
            font-size: 0.48rem;
          }
        }
        .btn {
          position: absolute;
          right: 16%;
          top: 73%;
          width: 1.946667rem;
          height: 0.586667rem;
          font-size: 0.32rem;
          text-align: center;
          line-height: 0.586667rem;
          color: #ffffff;
          background: -webkit-linear-gradient(top, #b22ff8, #1b82f1);
          border-radius: 0.4rem;
          animation: mymove 2s infinite;
          -webkit-animation: mymove 2s infinite; /*Safari and Chrome*/
          animation-direction: alternate; /*轮流反向播放动画。*/
          animation-timing-function: ease-in-out; /*动画的速度曲线*/
          /* Safari 和 Chrome */
          -webkit-animation: mymove 2s infinite;
          -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
        }
      }
    }
    .iteme {
      overflow: hidden;
      width: 10rem;
      margin-top: 0.266667rem;
      li:nth-child(2) {
        margin-left: 0.1653333rem;
      }
      ul li {
        margin-left: 0.266667rem;
        float: left;
        position: relative;
        width: 4.666667rem;
        margin-bottom: 0.16rem;
        height: 7.066667rem;
        overflow: hidden;
        border-radius: 0.266667rem;
        background: -webkit-linear-gradient(top, #edf4f6, #e3f4fc);
        .back {
          width: 100%;
          height: 4.56rem;
          border-radius: 0.266667rem;
          .one-hit {
            border-radius: 0.266667rem;
            width: 4.053333rem;
            height: 3.693333rem;
            margin-top: 0.266667rem;
            margin-left: 0.32rem;
          }
        }
        .text-one {
          width: 4.04rem;
          height: 0.63333rem;
          font-size: 0.373333rem;
          background-image: -webkit-linear-gradient(
            left,
            #208fec,
            #7d6ede,
            #b087f5
          );
          -webkit-background-clip: text;
          -webkit-text-fill-color: transparent;
          margin: 0 auto;
          font-weight: 900;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
        }
        .money-Hot {
          width: 3.733333rem;
          height: 0.533333rem;
          text-align: center;
          font-size: 0.426667rem;
          margin: 0 auto;
          font-weight: 600;
          color: #ff0000;
          span {
            font-size: 0.533333rem;
          }
        }
        .Go-hot {
          margin: 0.383333rem auto;
          width: 1.946667rem;
          height: 0.586667rem;
          font-size: 0.32rem;
          text-align: center;
          line-height: 0.586667rem;
          color: #ffffff;
          background: -webkit-linear-gradient(top, #b22ff8, #1b82f1);
          border-radius: 0.4rem;
          animation: mymove 2s infinite;
          -webkit-animation: mymove 2s infinite; /*Safari and Chrome*/
          animation-direction: alternate; /*轮流反向播放动画。*/
          animation-timing-function: ease-in-out; /*动画的速度曲线*/
          /* Safari 和 Chrome */
          -webkit-animation: mymove 2s infinite;
          -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
        }
      }
    }
  }
  .imas {
    display: block;
    width: 3.2rem;
    height: 1.28rem;
    margin: 0.466667rem auto;
  }
  .happy {
    width: 10rem;
    margin: 0 auto;
    overflow: hidden;
    ul li {
      margin-left: 0.222667rem;
      float: left;
      position: relative;
      width: 4.666667rem;
      margin-bottom: 0.16rem;
      height: 7.066667rem;
      overflow: hidden;
      border-radius: 0.266667rem;
      background: -webkit-linear-gradient(top, #edf4f6, #e3f4fc);
      .back {
        width: 100%;
        height: 4.56rem;
        border-radius: 0.266667rem;
        .one-hit {
          border-radius: 0.266667rem;
          width: 4.053333rem;
          height: 3.693333rem;
          margin-top: 0.266667rem;
          margin-left: 0.32rem;
        }
      }
      .text-one {
        width: 4.04rem;
        height: 0.63333rem;
        font-size: 0.373333rem;
        background-image: -webkit-linear-gradient(
          left,
          #208fec,
          #7d6ede,
          #b087f5
        );
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        margin: 0 auto;
        font-weight: 900;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
      }
      .money-Hot {
        width: 3.733333rem;
        height: 0.533333rem;
        text-align: center;
        font-size: 0.426667rem;
        margin: 0 auto;
        font-weight: 600;
        color: #ff0000;
        span {
          font-size: 0.533333rem;
        }
      }
      .Go-hot {
        margin: 0.383333rem auto;
        width: 1.946667rem;
        height: 0.586667rem;
        font-size: 0.32rem;
        text-align: center;
        line-height: 0.586667rem;
        color: #ffffff;
        background: -webkit-linear-gradient(top, #b22ff8, #1b82f1);
        border-radius: 0.4rem;
        animation: mymove 2s infinite;
        -webkit-animation: mymove 2s infinite; /*Safari and Chrome*/
        animation-direction: alternate; /*轮流反向播放动画。*/
        animation-timing-function: ease-in-out; /*动画的速度曲线*/
        /* Safari 和 Chrome */
        -webkit-animation: mymove 2s infinite;
        -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
      }
    }
  }
  .item {
    overflow: hidden;
    width: 10rem;
    ul li {
      position: relative;
      overflow: hidden;
      width: 9.6rem;
      height: 4.88rem;
      background: -webkit-linear-gradient(left, #edf4f6, #e3f4fc);
      border-radius: 0.266667rem;
      margin-bottom: 0.266667rem;
      margin-left: 0.206667rem;
      .Box {
        position: absolute;
        left: 5%;
        top: 12%;
        border-radius: 0.266667rem;
        width: 4rem;
        height: 2.293333rem;
        background: -webkit-linear-gradient(left, #208fec, #7d6ede, #b087f5);
        .text-Dev {
          margin: 0.133333rem auto;
          color: #ffffff;
          width: 3.413333rem;
          height: 1.173333rem;
          font-size: 0.426667rem;
          font-weight: 600;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
        }
        .money-Dev {
          position: absolute;
          top: 61%;
          left: 8%;
          width: 3.4rem;
          height: 0.8rem;
          font-weight: 600;
          font-size: 0.32rem;
          // font-weight: 600;
          color: #ffffff;
          span {
            font-size: 0.48rem;
          }
        }
      }
      .imge {
        float: right;
        width: 4.133333rem;
        height: 4.133333rem;
        background: #dddddd;
        margin-top: 0.366667rem;
        margin-right: 0.466667rem;
        border-radius: 0.166667rem;
      }
      .btn {
        position: absolute;
        right: 65%;
        top: 73%;
        width: 1.946667rem;
        height: 0.586667rem;
        font-size: 0.32rem;
        text-align: center;
        line-height: 0.586667rem;
        color: #ffffff;
        background: -webkit-linear-gradient(top, #b22ff8, #1b82f1);
        border-radius: 0.4rem;
        animation: mymove 2s infinite;
        -webkit-animation: mymove 2s infinite; /*Safari and Chrome*/
        animation-direction: alternate; /*轮流反向播放动画。*/
        animation-timing-function: ease-in-out; /*动画的速度曲线*/
        /* Safari 和 Chrome */
        -webkit-animation: mymove 2s infinite;
        -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
      }
    }
  }
  @keyframes mymove {
    0% {
      transform: scale(1); /*开始为原始大小*/
    }
    25% {
      transform: scale(1.1); /*放大1.1倍*/
    }
    50% {
      transform: scale(1);
    }
    75% {
      transform: scale(1.1);
    }
  }
  @-webkit-keyframes mymove /*Safari and Chrome*/ {
    0% {
      transform: scale(1); /*开始为原始大小*/
    }
    25% {
      transform: scale(1.1); /*放大1.1倍*/
    }
    50% {
      transform: scale(1);
    }
    75% {
      transform: scale(1.1);
    }
  }
}
</style>
